package com.example.programme.database;


import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class DBHelper extends SQLiteOpenHelper {

    private static final int VERSION = 1;//版本号
    private static final String DB_NAME = "myword.db";//库名
    public static final String TB_NAME1 = "tb_words";//表名


    public DBHelper(Context context, String name, CursorFactory factory,
                    int version) {
        super(context, name, factory, version);
    }
    public DBHelper(Context context) {
        super(context,DB_NAME,null,VERSION);
    }
/*创建数据库
*
 */
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE "+TB_NAME1+"(ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                "English TEXT,Cixing TEXT,Chinese TEXT)");

       // SQLiteDatabase db = dbHelper.getReadableDatabase();
        ContentValues values = new ContentValues();
        values.put("English", "spontaneous");
        values.put("Cixing", "adj.");
        values.put("Chinese","自发的，自然产生的" );
        db.insert(TB_NAME1, null, values);

        values.put("English", "compliment");
        values.put("Cixing", "n.");
        values.put("Chinese","称赞，恭维" );
        db.insert(TB_NAME1, null, values);
        values.put("English", "congnitive");
        values.put("Cixing", "adj.");
        values.put("Chinese","认知的，有认识力的" );
        db.insert(TB_NAME1, null, values);

        values.put("English", "notion");
        values.put("Cixing", "n.");
        values.put("Chinese","思想，观念" );
        db.insert(TB_NAME1, null, values);
        values.put("English", "consensus");
        values.put("Cixing", "adj.");
        values.put("Chinese","体面的，正派的" );
        db.insert(TB_NAME1, null, values);
        //初始数据

    }

    @Override
    public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
        // TODO Auto-generated method stub
    }

}